package view;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.WindowConstants;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

import controller.Maquina;
import controller.exception.MaquinaInstantiationException;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class CargarSimple extends javax.swing.JPanel {
	private JLabel jLabel1;
	private JLabel jLabel2;
	private JLabel jLabel3;
	private JButton jButton2;
	private JTextField textoCasilla1;
	private JButton botonAceptar;
	private static CargarSimple instancia; 
	
	/**
	* Auto-generated main method to display this 
	* JPanel inside a new JFrame.
	*/
	public static void main(String[] args) {
		JFrame frame = new JFrame();
		frame.getContentPane().add(new CargarSimple());
		frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		frame.pack();
		frame.setVisible(true);
	}
	
	private CargarSimple() {
		super();
		initGUI();
	}
	
	public static CargarSimple getInstancia()
	{
		if (instancia == null)
			instancia = new CargarSimple();
		return instancia;
	}
	
	private void initGUI() {
		try {
			this.setPreferredSize(new java.awt.Dimension(389, 243));
			this.setLayout(null);
			{
				jLabel1 = new JLabel();
				this.add(jLabel1);
				jLabel1.setText("Ingrese los nombres de fruta para cada Casilla:");
				jLabel1.setBounds(12, 12, 269, 24);
			}
			{
				jLabel2 = new JLabel();
				this.add(jLabel2);
				jLabel2.setText("(Manzana, Frutilla, Pera, Sandia, Banana)");
				jLabel2.setBounds(12, 42, 239, 25);
			}
			{
				botonAceptar = new JButton();
				this.add(botonAceptar);
				botonAceptar.setText("Agregar casilla");
				botonAceptar.setBounds(256, 178, 108, 38);
				
				botonAceptar.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt)
					{
						try {
							Maquina.getInstancia().crearCasillaSimple(textoCasilla1.getText());
						} catch (MaquinaInstantiationException e) {
							System.out.println("No hay ninguna Maquina creada");
						}
					}
				});
				
			}
			{
				jLabel3 = new JLabel();
				this.add(jLabel3);
				jLabel3.setText("Casilla 1");
				jLabel3.setBounds(24, 87, 68, 16);
			}
			{
				textoCasilla1 = new JTextField();
				this.add(textoCasilla1);
				textoCasilla1.setBounds(110, 84, 146, 23);
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	

}
